package config;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(value="/conf2",
			initParams = {@WebInitParam(name ="encoding",value = "GBK"),
						@WebInitParam(name="force",value="false")})
public class ConfServlet2 extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//1.得到config
		ServletConfig config = this.getServletConfig();
		//2.通过config得到参数
		System.out.println(config.getInitParameter("encoding"));
		System.out.println(config.getInitParameter("force"));
	}
}
